<?php 
include_once ('../global.php');
$show = $_GET['show'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link href="<?php echo CSS_PATH?>main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo JS_PATH?>jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH?>main.js"></script>
<title><?php echo $match_cn_name?>-成绩直播</title>
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js "></script>
 
<script>
    var  url=location.href;
	var wxdata;
		//alert(url.split("&")[0]);
		console.log(url.replace(/\&/g,"%26").replace(/\#/g,"%23"));
    $.ajax({
        type : "get",
        url : "http://live.scoringchina.com/scoringchina/wx/weixin_token/jssdk.php?url="+ url.replace(/\&/g,"%26").replace(/\#/g,"%23"),
        dataType : "jsonp",
        jsonp: "callback",
        jsonpCallback:"success_jsonpCallback",
        success : function(data){
			console.log(data);
			wxdata = data;
            wx.config({
                debug: false,
                appId: data.appId,
                timestamp: data.timestamp,
                nonceStr: data.nonceStr,
                signature: data.signature,
                jsApiList: [
                    'onMenuShareTimeline',//
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone'
 
                ]
            });
			console.log(wxdata);
        },
        error:function(data){
           // alert("连接失败！");
        }
    });
 
    wx.ready(function () {
        var shareData = {
            title: '<?php echo $match_cn_name?>-成绩直播',
            desc: '<?php echo $match_cn_name?>-成绩直播',
            link: url,
            imgUrl: 'http://live.scoringchina.com/scoringchina/2021volvochinaopen/mobile/images/volvo_logo.png'
        };
		//alert(wxdata.url);
		//alert(url);
        wx.onMenuShareAppMessage(shareData);//分享给好友
        wx.onMenuShareTimeline(shareData);//分享到朋友圈
        wx.onMenuShareQQ(shareData);//分享给手机QQ
        wx.onMenuShareWeibo(shareData);//分享腾讯微博
        wx.onMenuShareQZone(shareData);//分享到QQ空间
 
 
 
    });
    wx.error(function (res) {
		console.log(res);
       //  alert(res.errMsg);//错误提示
 
    });
	
	
	var pullrefresh = {
	init : function() {
		var pos = {};
		var status = false;
		var divobj = null;
		var contentobj = null;
		var reloadflag = false;
		$('body').on('touchstart', function(e) {
			e = mygetnativeevent(e);
			pos.startx = e.touches[0].pageX;
			pos.starty = e.touches[0].pageY;
		})
		.on('touchmove', function(e) {
			e = mygetnativeevent(e);
			pos.curposx = e.touches[0].pageX;
			pos.curposy = e.touches[0].pageY;
			if(pos.curposy - pos.starty < 0 && !status) {
				return;
			}
			if(!status && $(window).scrollTop() <= 0) {
				status = true;
				divobj = document.createElement('div');
				divobj = $(divobj);
				divobj.css({'position':'relative', 'margin-left':'-85px'});
				$('body').prepend(divobj);
				contentobj = document.createElement('div');
				contentobj = $(contentobj);
				contentobj.css({'position':'absolute', 'height':'30px', 'top': '-30px', 'left':'50%'});
				contentobj.html('<img src="./images/icon_arrow.gif" style="vertical-align:middle;margin-right:5px;-moz-transform:rotate(180deg);-webkit-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg);"><span id="refreshtxt">下拉可以刷新</span>');
				contentobj.find('img').css({'-webkit-transition':'all 0.5s ease-in-out'});
				divobj.prepend(contentobj);
				pos.topx = pos.curposx;
				pos.topy = pos.curposy;
			}
			if(!status) {
				return;
			}
			if(status == true) {
				var pullheight = pos.curposy - pos.topy;
				if(pullheight >= 0 && pullheight < 150) {
					divobj.css({'height': pullheight/2 + 'px'});
					contentobj.css({'top': (-30 + pullheight/2 + 60) + 'px'});
					if(reloadflag) {
						contentobj.find('img').css({'-webkit-transform':'rotate(180deg)', '-moz-transform':'rotate(180deg)', '-o-transform':'rotate(180deg)', 'transform':'rotate(180deg)'});
						contentobj.find('#refreshtxt').html('下拉可以刷新');
					}
					reloadflag = false;
				} else if(pullheight >= 150) {
					divobj.css({'height':pullheight/2 + 'px'});
					contentobj.css({'top': (-30 + pullheight/2 + 60 ) + 'px'});
					if(!reloadflag) {
						contentobj.find('img').css({'-webkit-transform':'rotate(360deg)', '-moz-transform':'rotate(360deg)', '-o-transform':'rotate(360deg)', 'transform':'rotate(360deg)'});
						contentobj.find('#refreshtxt').html('松开刷新');
					}
					reloadflag = true;
				}
			}
			e.preventDefault();
		})
		.on('touchend', function(e) {
			if(status == true) {
				if(reloadflag) {
					contentobj.html('<img src="./images/icon_load.gif" style="vertical-align:middle;margin-right:5px;">正在加载...');
					contentobj.animate({'top': (-30 + 75 + 60) + 'px'}, 618, 'linear');
					divobj.animate({'height': '75px'}, 618, 'linear', function() {
						window.location.reload();
					});
					return;
				}
			}
			divobj.remove();
			divobj = null;
			status = false;
			pos = {};
		});
	}
};
function mygetnativeevent(event) {
	while(event && typeof event.originalEvent !== "undefined") {
		event = event.originalEvent;
	}
	return event;
};
$(document).ready(function() {
	//console.log($('.pullrefresh').length)
	if($('.pullrefresh').length > 0) {
		pullrefresh.init();
	}
});
	
</script>
<style>
	#content_score {
		min-height: 360px;
		padding: 86px 0 40px;
	}
	.radius_fillet3 {
		border-radius: 3px;
	}

	.tt_bar {
		height: 30px;
		border-bottom: 1px solid #e3e3e3;
	}
	.score_title2 {
		height: 30px;
		border-bottom: 1px solid #e3e3e3;
		text-indent: 14px;
	}
	.score_back {
		text-align: right;
		padding-right: 14px;
	}
	.bt_back {
		display: inline-block;
		width: 40px;
		height: 18px;
		line-height: 18px;
		cursor: pointer;
		border: 1px solid #363636;
		color: #363636;
		font-size: 12px;
		text-align: center;
	}
	.score_tround {
		height: 30px;
		line-height: 30px;
	}
	.score_tround span {
		color: #363636;
		float: right;
		font-size: 18px;
		height: 26px;
		line-height: 32px;
		margin-right: 15px;
		text-align: center;
		width: 50px;
	}
	.index_news {
		padding: 0 15px;
	}
	#playoff{
		margin:15px;
		border:solid 1px #a9c6c9;
	}
	
	.SAME{
		background-color:#C60;
		color:white;
		font-size:10px;
		padding:3px;
	}
	
	.WNR{
		background-color:#6C3;
		color:white;
		font-size:10px;
		padding:3px;
	}
	
	.ELM{
		background-color:#C30;
		color:white;
		font-size:10px;
		padding:3px;
	}
	.country{
		color:#ef7ca3;
		}
	.playofftitle{
		background-color:white;
		color:#666;
		font-weight:bold;
		height:30px;
		font-size:15px;
	}
	.playoffhole{
		background-color:#F0F0F0;
		height:30px;
		color:#666;
		font-weight:bold;
		
		}
	.playoffplayer{
		border-bottom:solid 1px #FFF;
		height:30px;
	}
</style>
<!--header-->
<style>
	#navi_wait {
		height: 35px;
		background-color: #E3E3E3;
	}

	#navi_wait ul li {
		width: 32%;
		display: inline;
		float: left;
		/*line-height:33px;*/

		line-height: 36px;
		list-style-position: inside;
		border-bottom: 1px solid #A5A5A5;
		text-align: center;
	}

	#navi_wait ul li a {
		color: #767676;
		font-size: 19px;
		letter-spacing: 5px;
	}
	
	.scoringtable{
		border-radius:10px;  border-collapse: collapse;  border-style:hidden;  box-shadow: 0 0 0 1px #d8d8d8; overflow:hidden;
	}
	
	.topar{
		width:90%;
		height:28px;
		border-radius:10px;
		margin:auto auto auto auto;
		color:#fff;
		display:flex;
		justify-content:center;
		align-items:center;
		
	}
	.undereven{
		font-weight:bolder;
		background-color:#e50049;
		color:#fff;
	}
	.even{
		font-weight:bolder;
		background-color:#53565A;
		color:#fff;
	}
	.pluseven{
		font-weight:bolder;
		background-color:#1e213c;
		color:#fff;
	}
</style></head>

<body id="body">
 
	<div id="sta">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tbody>
				<tr>
					<td style="text-align:center;"><img src="./images/3.png" style="width:350px;height:80px" /></td>
				</tr>
			</tbody>
		</table>
	</div>


	<div id="content_score" style="">
		  <div class="pullrefresh" style="display:none;"></div>

		<div class="clear_h10" style="clear:both; height:10px;"></div>
		<div id="con1" class="index_news">
			<div id="allstars">
			<table class="altrowstable scoringtable">
				<tr>
					
								<td style="border:none; vertical-align:middle;">
								<font style="font-weight:bolder;font-size:17px;"><?php echo $match_cn_name?></font>
								</td>
									<td style="border:none; vertical-align:middle;">		
										<a href="group.php?mt_id=<?php echo $mt_id?>" style="float:right; padding-right:20px;margin-top:3px;">分组表</a>
									</td>
													
				</tr>
			</table>
			<table class="altrowstable scoringtable" style="margin-top:5px;">	
				<tbody id="asman">
				<tr>
					<th width="8%" style="background-color:#1e213c;color:#fff">#</th>
					<th width="47%" style="background-color:#1e213c;color:#fff">Players</th>
					<?php
					for($i=1;$i<=$maxRound;$i++){
                    	echo '<th width="7%" style="background-color:#1e213c;color:#fff">R'.$i.'</th>';
                    }	
					?>		
					<th width="10%"  style="background-color:#1e213c;color:#fff">Score</th>
					<th width="7%" style="background-color:#1e213c;color:#fff">Thru</th>
				</tr>
<?php
function toparcolor_mobile($score){
	if (!empty($score)){
		if ($score<='-2'){
            $color = 'mtwo';
        } else if ($score=='-1'){
            $color = 'mone';
        } else if ($score=='0'){
            $color = 'eng';
        } else if ($score=='1'){
            $color = 'pone';
        } else if ($score>='2'){
            $color = 'ptwo';
        } else {
            $color = 'eng';
        }
	} else {
		$color = 'eng';
	}
	return $color;
}


$start_hole = startHole($mt_id,$rd_id);
$holeScore   = getHoleScore($mt_id,$rd_id);        //当前洞和当前轮的topar
$score       = getScore($mt_id);                   //比赛成绩读取
for ($r=1;$r<=$rd_id;$r++){
    if (!empty($score['to_par'])){
        foreach ($score['to_par'] as $k => $v){
            $topar[$k] += $v[$r];
        }
    }
}
$summary = playerSummary($mt_id,$rd_id);       //当前轮
$rank = $summary['rank'];
$k=1;
$b=1;
if ($rank){
	foreach ($rank as $i => $n){
		echo '<tr '.(($k%2==0)?'class="oddrowcolor"':'').'>
				<td width="8%">'.((empty($n))?'-':$n).'</td>
				<td align="left" style="text-align:left;" width="47%">
					<a href="detail.php?mt_id='.$mt_id.'&pl_id='.$i.'"><span style="color:#1e213c;font-style:italic">'.$players['playerCountry'][$i].'</span>&nbsp;&nbsp;'.$players['playerName'][$i].'&nbsp;&nbsp;'.$players['playerEnName'][$i].(($players['playerType'][$i]=='AMA')?'(A)':'').'</a>'.(($players['playerSex'][$i] == 0)?'&nbsp;<img src="./images/lady.png" width="10" height="10" style="padding-top:5px;padding-left:5px;" >':'').'
				</td>';
		for($r=1;$r<=$maxRound;$r++){
			if ($holeScore['thru'][$i]=='18'){
			  echo '<td width="7%"><span '.(($score['to_par'][$i][$r]<0)?'style="color:#e50049;"':'').'>'.(($score['rd_score'][$i][$r])?$score['rd_score'][$i][$r]:'-').'</span></td>';
			}
			else{
			  echo '<td width="7%"><span '.(($score['to_par'][$i][$r]<0)?'style="color:#e50049;"':'').'>'.(($score['to_par'][$i][$r]=='0') ? 'E' : (($score['to_par'][$i][$r]=='') ? '' : (($score['to_par'][$i][$r]>0) ? '+'.$score['to_par'][$i][$r] : $score['to_par'][$i][$r]))).'</span></td>';
			}
		}
		echo '<td width="10%" ><div class="topar '.(($topar[$i]<0)?'undereven"':(($topar[$i]==0)?'even"':(($topar[$i]>0)?'pluseven"':'"'))).'>'.(($topar[$i]=='0') ? 'E' : (($topar[$i]=='') ? '' : (($topar[$i]>0) ? '+'.$topar[$i] : $topar[$i]))).'</div></td>';
		if ($holeScore['thru'][$i]=='18'){
			if ($summary['checked'][$i]=='C'){
				echo '<td width="7%" style="color:#1e213c;font-weight:bolder;"> F </td>';
			} else {
				echo '<td width="7%" > F </td>';
			}
		} else {
			if ($holeScore['thru'][$i]!=""){
				echo '<td width="7%">'.$holeScore['thru'][$i].' '.(($start_hole[$i] == 10) ? '*':'').'</td>';
			} else {
			  echo '<td width="7%">-</td>';
			}
		}
		echo '</tr>';
		if ($k%10==0){
			if($b == 1){
				echo '<tr class="oddrowcolor"><td colspan="8" style="text-align:center;background-color:#fff;"><img src="./images/1.png" style="width:350px;height:80px"></td></tr>';
			}
			
            echo '<tr>
                    <th width="8%" style="background-color:#1e213c;color:#fff">#</th>
                    <th width="47%" style="background-color:#1e213c;color:#fff">Players</th>';
            for($i=1;$i<=$maxRound;$i++){
            	echo '<th width="7%" style="background-color:#1e213c;color:#fff">R'.$i.'</th>';
            }
            echo '<th width="10%" style="background-color:#1e213c;color:#fff">Score</th>
                    <th width="7%" style="background-color:#1e213c;color:#fff">Thru</th>
                </tr>';
				$b++;
		}	
		$k++;
	}
}
?>				
				
				</tbody>
			</table>
			</div>
		</div>


		<div id="con2" class="index_news" style="display: none;">
			<div id="as_con"><font style="font-weight:bolder;font-size:17px;"><?php echo $match_cn_name?></font></div>
			<div class="score_round">
				<?php
				for($i=$maxRound;$i>=1;$i--){
                	echo '<span class="jq_rclk" '.(($i==$rd_id)?'style="border-radius:10px;background-color:#141414;color:#fff;"':'').'><a '. (($i==$rd_id)?'style="color:#fff;"':'').'  href="?mt_id='.$mt_id.'&rd_id='.$i.'">R'.$i.'</a></span>';
                }	
				?>
				<input type="hidden" id="round_num" name="round_num" value="" data-role="none">
			</div>


			<table class="altrowstable scoringtable" id="k_as_man">
				<tbody>
					<tr>
						<th width="2%" rowspan="2" style="background-color:#1e213c;color:#fff"> Pos </th>
						<th width="15%" rowspan="2" style="background-color:#1e213c;color:#fff"> Players </th>
						<th width="3%" rowspan="2" style="background-color:#1e213c;color:#fff"> After </th>
						<th width="4%" rowspan="2" style="background-color:#1e213c;color:#fff"> TP </th>
						<th width="4%" rowspan="2" style="background-color:#1e213c;color:#fff"> TD </th>
						<th width="2%" style="background-color:#1e213c;color:#fff">1</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">2</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">3</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">4</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">5</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">6</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">7</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">8</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">9</th>
						<th width="3%" style="background-color:#1e213c;color:#fff">OUT</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">10</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">11</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">12</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">13</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">14</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">15</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">16</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">17</th>
						<th width="2%" style="background-color:#1e213c;color:#fff">18</th>
						<th width="3%" style="background-color:#1e213c;color:#fff">IN</th>
						<?php
						for($i=1;$i<=$maxRound;$i++){
							echo '<th width="3%" rowspan="2" style="background-color:#1e213c;color:#fff">R'.$i.'</th>';
						}
						?>
						<th width="3%" rowspan="2" style="background-color:#1e213c;color:#fff"> Total </th>
					</tr>
					<tr>
						<?php
                            $out_total = $in_total = 0;
                            for ($i=1;$i<10;$i++){
                                echo '<th class="clspar" style="background-color:#1e213c;color:#fff">'.$pars["par"][($i-1)].'</th>';
                                $out_total += $pars["par"][($i-1)];
                            }
                            echo '<th class="clspar" style="background-color:#1e213c;color:#fff">'.$out_total.'</th>';

                            for ($i=10;$i<19;$i++){
                                echo '<th class="clspar" style="background-color:#1e213c;color:#fff">'.$pars["par"][($i-1)].'</th>';
                                $in_total += $pars["par"][($i-1)];
                            }
                            echo '<th class="clspar" style="background-color:#1e213c;color:#fff">'.$in_total.'</th>';
                        ?>
					</tr>
<?php
$k=1;
foreach ($rank as $i => $n){
	echo '<tr '.(($k%2==0)?'class="oddrowcolor"':'').'>
			<td>'.((empty($n))?'-':$n).'</td>
			<td style="text-align:left;"><span style="color:#1e213c;font-style:italic">'.$players['playerCountry'][$i].'</span>&nbsp;&nbsp;'.$players['playerName'][$i].'&nbsp;&nbsp;'.$players['playerEnName'][$i].(($players['playerType'][$i]=='AMA')?'(A)':'').(($players['playerSex'][$i] == 0)?'&nbsp;<img src="./images/lady.png" width="10" height="10" style="padding-top:5px;padding-left:5px;" >':'').'</td>';
	//完成洞数
    if ($holeScore['thru'][$i]=='18'){
        if ($summary_648['checked'][$i]=='C'){
            echo '<td> F </td>';
        } else {
            echo '<td> F </td>';
        }
    } else {
        if ($holeScore['thru'][$i]!=""){
            echo '<td>'.$holeScore['thru'][$i].' '.(($start_hole[$i] == 10) ? '*':'').'</td>';
        } else {
          echo '<td></td>';
        }
    }
   echo '<td ><div class="topar '.(($topar[$i]<0)?'undereven"':(($topar[$i]==0)?'even"':(($topar[$i]>0)?'pluseven"':'"'))).'>'.(($topar[$i]=='0') ? 'E' : (($topar[$i]=='') ? '' : (($topar[$i]>0) ? '+'.$topar[$i] : $topar[$i]))).'</div></td>';
	echo	  '<td '.(($score['to_par'][$i][$rd_id]<0)?'style="color:#e50049;"':'').'>'.(($score['to_par'][$i][$rd_id]=='0') ? 'E' : (($score['to_par'][$i][$rd_id]=='') ? '' : (($score['to_par'][$i][$rd_id]>0) ? '+'.$score['to_par'][$i][$rd_id] : $score['to_par'][$i][$rd_id]))).'</td>';
	//18洞成绩
    $out_score = $in_score = 0;
    for ($h=1;$h<10;$h++){
        echo '<td class="'.toparcolor_mobile($holeScore['topar'][$i][$h]).'">'.$holeScore['score'][$i][$h].'</td>';
        $out_score += $holeScore['score'][$i][$h];
    }
    echo '<td class="inout">'.$out_score.'</td>';
    for ($h=10;$h<19;$h++){
        echo '<td class="'.toparcolor_mobile($holeScore['topar'][$i][$h]).'">'.$holeScore['score'][$i][$h].'</td>';
        $in_score += $holeScore['score'][$i][$h];
    }
    echo '<td class="inout">'.$in_score.'</td>';

    //R1-R4成绩
    $totalscore = '';
    for($r=1;$r<=$maxRound;$r++){
        if ($r<=$rd_id){
            echo '<td class="rtotal">'.$score['rd_score'][$i][$r].'</td>';
            $totalscore += $score['rd_score'][$i][$r];
        } else {
            echo '<td class="rtotal">-</td>';
        }
    }
    echo '<td class="inout">'.$totalscore.'</td>';
	echo '</tr>';
	$k++;
}
?>
				<tr class="oddrowcolor"><td colspan="30" style="text-align:center;background-color:white;"><img src="./images/2.png" style="width:100%;height:auto;"></td></tr>
				</tbody>
			</table>


			
			
			


		



		</div>
	</div>
	<div style="text-align:centre;display:flex;justify-content: center;">
			<img src="./images/ad.jpg" style="width:100%;height:100%"></div>
	</div>
<div id="bottom" style="background-color:#fff;text-align:centre;display:flex;justify-content: center;">
	<div id="bootom-top">
        <span style="width:100%;text-align:center">技术支持  @斯科云科技</span>
        <script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279000992'%3E%3C/span%3E%3Cscript src='https://s4.cnzz.com/z_stat.php%3Fid%3D1279000992%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script>
		<a href="#body" target="_self">回顶部</a>
	</div>
</div>
</body>
</html>